package com.fly.filter;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 登录检查
 */
public class logincheck implements HandlerInterceptor {
    /**
     * 目标方法执行之前
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session=request.getSession();
        Object loginUser =session.getAttribute("id");
        String requestURI = request.getRequestURI();
        String url= "/templates/backed/pages/fronts/**";

        //判断是否需要拦截
        if (loginUser!=null){
            return true;
        }
       //response.sendRedirect("/templates/backed/login.html");

        return false;
    }
}
